﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Web;

namespace SYH178Utils
{
    public class Config
    {
        public static string GetWebConfig(string key)
        {
            return ConfigurationManager.AppSettings[key];
        }
        private static string GetConnection(string key)
        {
            return ConfigurationManager.ConnectionStrings[key].ConnectionString;
        }
        #region 数据库链接字符串
        /// <summary>
        /// 数据库连接字符串
        /// </summary>
        public static string SYHConnStr
        {
            get { return GetWebConfig("SYH178"); }
        }

        #endregion

        public static string[] SupperAdminNames
        {
            get
            {
                string supperAdminNames = GetWebConfig("SupperAdminNames");
                return supperAdminNames.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            }
        }

        public static System.Xml.Linq.XElement menuList;
        public static System.Xml.Linq.XElement MenuList
        {
            get
            {
                if (menuList == null)
                {
                    menuList = System.Xml.Linq.XElement.Load(HttpContext.Current.Server.MapPath("~/App_Data/MenuListLeft.xml"));
                }
                return menuList;
            }
        }

        /// <summary>
        /// 每页几条数据
        /// </summary>
        public static string pageSize
        {
            get
            {
                return ConfigurationManager.AppSettings["pageSize"];
            }
        }

    }
}
